#!/usr/bin/python
# Disponivel no pacote de programas como: lhs.py
from pylab import plot, figure,hist,show, savefig
import scipy.stats as stats
import numpy

def lhs(dist, parms, n=100):
    perc = numpy.arange(0,1.,1./n)
    smp = [stats.uniform(i,1./n).rvs() for i in perc]
    v = dist(parms[0],1./parms[1]).ppf(smp)
    return v
            
if __name__=='__main__':
    c=lhs(stats.norm, [0,1],20)
    hist(c)
    n = stats.norm.rvs(size=20)
    hist(n.ravel(),facecolor='r',alpha =0.3)
    savefig('lhs.png',dpi=400)
    show()
    
